<div id="page-wrapper">
        <!-- /.row -->
    <div class="row">
        <div class="col-sm-12">
            <div class="panel panel-default">
                <div class="panel-heading"><span class="judul-page">Edit Master Pegawai</span></div>
                <div class="panel-body">
					<?php 
						echo form_open_multipart('mr_pegawai/update', array('class' => 'form-horizontal', 'role' => 'form')); 
						foreach ($list as $row){ 
					?>
						<input type="hidden" name="id_mr_pegawai" value="<?php echo $row->id_mr_pegawai; ?>">
						
						<div class="form-group">
							<label class="col-sm-2 control-label">Nama Lengkap</label>
							<div class="col-sm-5">
								<input type="text" name="nm_pegawai" class="form-control input-sm" value="<?php echo  $row->nm_pegawai;?>" placeholder="Nama Lengkap">
							</div>
							<div class="col-sm-2">
								<input type="text" class="form-control input-sm" disabled name="nip" value="NIP: <?php echo $row->nip; ?>">
							</div>
						</div>
					  
					 <div class="form-group">
                        <label class="col-sm-2 control-label">Jenis Kelamin</label>
                        <div class="col-sm-9">
                            <label class="radio-inline">
								<input type="radio" name="jk" value="L" <?php if ($row->jk == 'L'){echo "checked";} ?>>
								Laki-laki
							</label>

							<label class="radio-inline">
								<input type="radio" name="jk" value="P" <?php if ($row->jk == 'P'){echo "checked";} ?>>
								Perempuan
							</label>
                        </div>
                      </div>

						<div class="form-group">
							<label class="col-sm-2 control-label">TTL</label>
							<div class="col-sm-4">
								<input type="text" name="tmp_lahir" class="form-control input-sm" placeholder="Tempat Lahir" value="<?php echo $row->tmp_lahir; ?>">
							</div>
							<div class="col-sm-2">
								<input type="text" name="tgl_lahir" class="form-control input-sm tanggal" placeholder="Tanggal Lahir" value="<?php echo date("d-m-Y", strtotime ($row->tgl_lahir)); ?>">
							</div>
						</div>
					
					<div class="form-group">	
						<label class="col-sm-2 control-label">Ijazah Terakhir</label>
						<div class="col-sm-3">
							<select name="ijazah_akhir" class="form-control input-sm">
								<?php 
								foreach ($list_p->result() as $row_p){ 
								
									if($row_p->id_mr_pendidikan==$list[0]->ijazah_akhir){
									?>
										<option selected value="<?php echo $row_p->id_mr_pendidikan; ?>"><?php echo  $row_p->pendidikan; ?></option>
									<?php
									}else{
									?>
										<option value="<?php echo $row_p->id_mr_pendidikan; ?>"><?php echo  $row_p->pendidikan; ?></option>							
									<?php
									}
								}; 
								?>
							</select>
						</div>
					</div>
		
						
					<div class="form-group">	
					<label class="col-sm-2 control-label">Agama</label>
					<div class="col-sm-9">
							<?php 
							foreach ($list_a->result() as $row_a){ 
								if($row_a->id_mr_agama==$list[0]->id_mr_agama){
								?>
									<label class="radio-inline">
										<input type="radio" name="id_mr_agama" value="<?php echo $row_a->id_mr_agama; ?>" checked>
										<?php echo $row_a->agama; ?>
									</label>
								<?php
								}else{
								?>
									<label class="radio-inline">
										<input type="radio" name="id_mr_agama" value="<?php echo $row_a->id_mr_agama; ?>">
										<?php echo $row_a->agama; ?>
									</label>
								<?php
								}
							}; 
							?>
					</div>
				</div>
						
						<div class="form-group">
							<label class="col-sm-2 control-label">No. Tlp</label>
							<div class="col-sm-4">
							  <input type="text" name="tlp" class="form-control input-sm" value="<?php echo $row->tlp; ?>" placeholder="No. Tlp">
							</div>
						</div>
						
						<div class="form-group">
							<label class="col-sm-2 control-label">Email</label>
							<div class="col-sm-4">
							  <input type="text" name="email" class="form-control input-sm" value="<?php echo $row->email; ?>" placeholder="Email">
							</div>
						</div>
					  
						<div class="form-group">
							<label class="col-sm-2 control-label">Alamat</label>
							<div class="col-sm-7">
								<textarea name="alamat" class="form-control input-sm" rows="3" placeholder="Alamat Lengkap"><?php echo $row->alamat; ?></textarea>
							</div>
						</div>
						
                      <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-9">
                          <button type="submit" onClick="validate()" class="btn btn-primary btn-sm">Update</button>
                          <button type="reset" class="btn btn-danger btn-sm" onclick="history.back(-1)">Batal</button>
                        </div>
                      </div>
                    <?php 
						}
						echo form_close();
					?>
                </div>
            </div>
        </div>
    </div>
    <!-- /.row -->
</div>
<!-- /#page-wrapper -->

<script>
  function validate() {
    $("form").validate({
      rules: {
        nm_pegawai: {
          required: true
        },
        tmp_lahir: {
          required: true
        },
        tgl_lahir: {
          required: true
        },
        tlp: {
          required: true
        },
        email: {
          required: true
        },
        alamat: {
          required: true
        },
      },
      messages: {
        nm_pegawai: {
          required: "Nama Pegawai harus diisi."
        },
        tmp_lahir: {
          required: "Tempat Lahir harus diisi."
        },
        tgl_lahir: {
          required: "Tanggal Lahir harus diisi."
        },
        tlp: {
          required: "Telepon harus diisi."
        },
        email: {
          required: "Email harus diisi."
        },
        alamat: {
          required: "Alamat harus diisi."
        },
      }
    });

    var topicInputs = topics.find("input").attr("disabled", !inital);
  };
</script>